﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;


namespace mscook.core.domain
{
    public class CookBook : Entity
    {
        
        public CookBook()
        {
            ResourceBonusSetting = new ResourceBonusSetting(Id,0,PurchasedCategory.CookBook);
        }

        [Required(ErrorMessage = "菜名必填")]
        [StringLength(12, ErrorMessage = "菜名最长12位")]
        public virtual string Name
        {
            get;
            set;
        }

        public virtual Chef Chef
        {
            get;
            set;
        }
        [Required(ErrorMessage = "编辑必填")]
        public virtual string Editor
        {
            set;
            get;
        }
        public virtual string Summary
        {
            set;
            get;
        }
        public virtual string ImageName
        {
            get;
            set;
        }
        public virtual string Description
        {
            get;
            set;
        }

        public virtual ResourceBonusSetting ResourceBonusSetting
        {
            set;
            get;
        }
      

        public virtual Iesi.Collections.Generic.ISet<MaterialOfCookBook> MaterialOfCookBooks
        {
            get;
            set;
        }

        [Required(ErrorMessage = "积分必填")]
        [RegularExpression(@"^[0-9]*$", ErrorMessage = "请填写正确的数字")]
        public virtual int AbsBonus
        {
            set
            {
                ResourceBonusSetting.Bonus = -Math.Abs(value);
            }
            get
            {
                return Math.Abs(ResourceBonusSetting.Bonus);
            }
        }


    }
}
